package com.zhj.test.nio;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * @author zhj
 */
public class NIOFileChannel04 {
    public static void main(String[] args) throws IOException {
        File file1 = new File("E:\\data_file\\img01.jpg");
        File file2 = new File("E:\\data_file\\img02.jpg");
        // 创建一个输出流
        FileInputStream fileInputStream = new FileInputStream(file1);
        FileChannel fileChannel01 = fileInputStream.getChannel();
        // 创建一个输出流
        FileOutputStream fileOutputStream = new FileOutputStream(file2);
        FileChannel fileChannel02 = fileOutputStream.getChannel();
        fileChannel02.transferFrom(fileChannel01,0, fileChannel01.size());
        fileInputStream.close();
        fileOutputStream.close();
    }
}
